#include <bits/stdc++.h>
// 2025/02/06
// tag: 
// Author: Zhang Muen
using namespace std;

using int64 = int64_t;

int n, m, presum[2501], dp[2501];

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
    cin >> n >> m;
    presum[0] = m * 2;
    for (int i = 1; i <= n; i++)
        cin >> presum[i], presum[i] += presum[i - 1], dp[i] = presum[i];
    for (int i = 1; i <= n; i++){
        for (int j = i; j <= n; j++){
            dp[j] = min(dp[j], dp[j - i] + presum[i]);
        }
    }
    cout << dp[n] - m << endl;
    return 0;
}